<?php
/**
 * Smarty plugin
 * 
 * $Id: modifier.repeat.php 121 2010-05-28 07:57:29Z Administrator $
 * $Revision: 121 $
 * $Author: Administrator $
 * $Date: 2010-05-28 15:57:29 +0800 (星期五, 28 五月 2010) $
 * @package fastlib
 * @subpackage smarty
 */
/**
 * Smarty repeat modifier plugin
 *
 * Type:	modifier<br />
 * Name:	repeat<br />
 * 
 * @author glzaboy <glzaboy@163.com>
 * @param string $string 
 * @param Int $number 重复次数
 * @param pattern $search 正则替换
 * @return string
 */
function smarty_modifier_repeat($string, $number = 2, $search = null) {
	if (! isset ( $search )) {
		return str_repeat ( $string, $number );
	} else {
		$match = null;
		if (preg_match ( $search, $string, $match )) {
			return preg_replace ( $search, str_repeat ( array_shift ( $match ), $number ), $string );
		}
	}
	return '';
}